package com.puhui.education.util;

import android.app.Activity;
import android.content.Intent;

import com.puhui.education.R;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2016/6/15.
 */
public class IntentUtil {
    public static void startActivity(Activity activity, Class<?> cls) {
        Intent intent = new Intent(activity, cls);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_enter_anim, R.anim.activity_exit_anim);
    }

    /**
     * 启动Activity
     *
     * @param cls    启动的类
     * @param params 参数，只支持String参数
     */
    public static void startActivity(Activity activity, Class<?> cls, Map<String, String> params) {
        Intent intent = new Intent(activity, cls);
        Set<String> keySet = params.keySet();
        Iterator<String> iterator = keySet.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            intent.putExtra(key, params.get(key));
        }
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_enter_anim, R.anim.activity_exit_anim);
    }

}
